//app.js
App({
  onLaunch: async function () {
    wx.showLoading({
      title: '加载中...',
    })
    await this.getAppConfig();
    wx.hideLoading();
    this.globalData = {
      userInfo: {},
      canIUseGetUserProfile: false,
      hasUserInfo: false
    }
  },

   getAppConfig: async function(){
    await wx.request({
      url: 'https://www.somekey.cn/mini/hero/getHeroConfig.json',
      success: res => {
        if (res.data.code == 200) {
          var result = res.data.data;
          wx.setStorageSync('appConfig', result);
          if (result.notice.switch) {
            wx.showModal({
              title: '温馨提示',
              content: result.notice.content,
              showCancel: false,
              cancelText: "否",
              confirmText: "好的",
              success: function (res) {
                wx.setStorageSync('readNotice', true);
              },
            })
          }
        } else {
          wx.showToast({
            title: '加载失败',
            icon: 'info'
          })
        }
      },
      complete: () => {
        wx.hideLoading();
      }
    })
  },

})
